/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2023-03-10
 * Time: 18:06
 */
public class test {
    public static boolean parity(int[] arr){
        int flag = 0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] % 2 != 0){
                flag++;
            }else {
                flag = 0;
            }
            if(flag == 3){
                return true;
            }
        }
        return false;
    }
    public static void main(String[] args) {
        int[] arr = {2,6,4,1,5,9,12};
        boolean ret = parity(arr);
        System.out.println(ret);
    }
    public static int Maxnum(int[] arr){
        int num = arr[0];
        int count = 1;
        for(int i = 1; i < arr.length; i++){
            if(count > 0){
                if(num == arr[i]) {
                    count ++;
                }
                else{
                    count --;
                }
            }
            else {
                num = arr[i];
                count = 1;
            }
        }
        return num;
    }
    public static void main5(String[] args) {
        int[] arr = {2,2,1,1,1,2,2};
        int ret = Maxnum(arr);
        System.out.println(ret);
    }
    public static int search(int[] arr){
        int i ;
        int ret = 0;
        for (i = 0; i < arr.length; i++) {
            ret ^= arr[i];
        }
        return ret;
    }
    public static void main4(String[] args) {
        int[] arr = {2,2,4,6,4,7,6};
        int ret = search(arr);
        System.out.println(ret);
    }
    public static int[] summ(int[] arr, int k){
        int[] strr = new int[2];
        for (int i = 0; i < arr.length; i++) {
            for (int j = i + 1; j < arr.length; j++) {
                if(arr[i] + arr[j] == k){
                    strr[0] = i;
                    strr[1] = j;
                    break;
                }
            }
        }
        return strr;
    }
    public static void main3(String[] args) {
        int[] nums = {2,7,11,15};
        int target = 13;
        int[] arr = summ(nums,target);
        for (int i = 0; i < 2 ; i++) {
            System.out.print(arr[i]+" ");
        }
    }
    public static void bubi(int[] arr){
        int j ;
        for (int i = 0; i < arr.length - 1; i++) {
            for (j = 0; j < arr.length - 1 - i; j++) {
                if(arr[j] > arr[j + 1]){
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                }
            }
            System.out.println(arr[i]);
        }
    }
    public static void main2(String[] args) {
        int[] arr = {1,3,2,5,6,8,4,7,9,10};
        bubi(arr);
    }
    public static int search(int[] arr,int k){
        int left = 0;
        int right = arr.length - 1;
        while(left <= right){
            int m = (left + right) / 2;
            if(arr[m] < k){
                left = m + 1;
            } else if(arr[m] > k){
                right = m - 1;
            }else{
                return m;
            }
        }
        return -1;
    }
    public static void main1(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,8,9,10,11};
        int ret = search(arr,11);
        System.out.println(ret);
    }
    public static void exchange(int[] arr){
        for (int i = 0; i <arr.length ; i++) {
            for (int j = i+1; j <arr.length ; j++) {
                if(arr[j] % 2 != 0){
                    int tmp = arr[j];
                    arr[j] = arr[i];
                    arr[i] = tmp;
                }
            }
            System.out.print(arr[i]+" ");
        }
    }
    public static void main0(String[] args) {
        int[] arr = {1,2,3,4,5,6};
        exchange(arr);
    }
}
